﻿<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="Bookmark" href="/favicon.ico" >
        <link rel="Shortcut Icon" href="/favicon.ico" />
        <!--[if lt IE 9]>
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/html5shiv.js"></script>
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/respond.min.js"></script>
        <![endif]-->
        <link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui/css/H-ui.min.css" />
        <link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui.admin/css/H-ui.admin.css" />
        <link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/lib/Hui-iconfont/1.0.8/iconfont.css" />
        <link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui.admin/skin/default/skin.css" id="skin" />
        <link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui.admin/css/style.css" />
        <!--[if IE 6]>
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
        <title>权限列表</title>
    </head>
    <body>
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员配置 <span class="c-gray en">&gt;</span> 权限列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
        <div class="page-container">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                    <tr>
                        <th scope="col" colspan="11">
                            <span class="l">权限列表</span>
                            <span class="r">
                                <a href="javascript:;" onclick="delAll()" class="btn btn-danger radius">
                                    <i class="Hui-iconfont">&#xe6e2;</i> 批量删除
                                </a> 
                                <a href="javascript:;" onclick="message_add('添加通知', 'messageAdd', '800', '500')" class="btn btn-primary radius">
                                    <i class="Hui-iconfont">&#xe600;</i> 添加通知
                                </a>
                            </span>
                        </th>
                    </tr>
                    <tr class="text-c">
                        <th width="25"><input type="checkbox"></th>
                        <th width="40">ID</th>
                        <th width="150">标题</th>
                        <th width="200">内容</th>
                        <th width="100">创建时间</th>
                        <th width="60">是否发布</th>
                        <th width="60">操作</th>
                    </tr>
                </thead>
                <tbody>
                {foreach name="message" item="vo" key="k"}
                    <tr class="text-c">
                        <td><input type="checkbox" value="{$vo.id}" name="id[]"></td>
                        <td>{$vo.id}</td>
                        <td>{$vo.m_title}</td>
                        <td>{$vo.m_content}</td>
                        <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                        <td class="td-status">
                            {switch $vo.status}
                                {case 0}<span class="label label-default radius">停用</span>{/case}
                                {case 1}<span class="label label-success radius">发布</span>{/case}
                            {/switch}
                        </td>
                        <td class="td-manage">
                            {switch $vo.status}
                                {case 0}<a onClick="admin_start(this,'{$vo.id}')" href="javascript:;" title="发布" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>{/case}
                                {case 1}<a onClick="admin_stop(this, '{$vo.id}')" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>{/case}
                            {/switch}
                            <a title="编辑" href="javascript:;" onclick="message_edit('权限编辑', '{:url('system/messageAdd',array('id'=>$vo.id))}', '{$vo.id}', '800', '500')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                            <a title="删除" href="javascript:;" onclick="message_del(this, '{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                        </td>
                    </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
        <!--_footer 作为公共模版分离出去-->
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/jquery/1.9.1/jquery.min.js"></script> 
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/layer/2.4/layer.js"></script>
        <script type="text/javascript" src="__STATIC__/admin/hui/static/h-ui/js/H-ui.min.js"></script> 
        <script type="text/javascript" src="__STATIC__/admin/hui/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

        <!--请在下方写此页面业务相关的脚本-->
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
        <script type="text/javascript" src="__STATIC__/admin/hui/lib/laypage/1.2/laypage.js"></script>
        <script type="text/javascript">
            $(function(){
                $('.table-sort').dataTable({
                    "aaSorting": [[ 4, "desc" ]],//默认第几个排序
                    "bStateSave": true,//状态保存
                    "aoColumnDefs": [
//                        {"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                        {"orderable":false,"aTargets":[0,2,3,6]}// 制定列不参与排序
                    ]
                });
            });
            /*管理员-增加*/
            function message_add(title, url, w, h) {
                layer_show(title, url, w, h);
            }
            /*管理员-删除*/
            function message_del(obj, id) {
                layer.confirm('确认要删除id为'+id+'的数据吗？', function (index) {
                    $.ajax({
                        type: 'POST',
                        data:{'id': id},
                        url: "{:url('system/messageDel')}",
                        dataType: 'json',
                        success: function (data) {
//                            $(obj).parents("tr").remove();
                            layer.msg(data, {icon: 1, time: 1000},function(){
                                location.reload();
                            });
                        },
                        error: function (data) {
                            console.log(data.msg);
                        },
                    });
                });
            }
            /*管理员-批量删除*/
            function delAll(){
                var chk_value =[];
                $('input[name="id[]"]:checked').each(function(){ 
                    chk_value.push($(this).val());
                });
                chk_value.length==0 ? $.Huimodalalert('你还没有选择任何内容！',2000): message_del(this, chk_value.join(','));
            }
            /*管理员-编辑*/
            function message_edit(title, url, id, w, h) {
                layer_show(title, url, w, h);
            }
            /*管理员-状态变更*/
            function status_change(id, status) {
                    $.ajax({
                        type: 'POST',
                        data:{'id': id,'status':status},
                        url: "{:url('system/messageStatusChg')}",
                        dataType: 'json',
                        async: false,
                        success: function (data) {
                            res = data;
                        },
                        error: function (data) {
                            console.log(data.msg);
                            res = false;
                        },
                    });
                return res;
            }
            /*管理员-停用*/
            function admin_stop(obj, id) {
                layer.confirm('确认要停用吗？', function (index) {
                    var re = status_change(id, '0');
                    if(re){
                    $(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,'+id+')" href="javascript:;" title="发布" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">停用</span>');
                    $(obj).remove();
                    layer.msg('已停用!', {icon: 5, time: 1000});
                    }
                });
            }
            /*管理员-发布*/
            function admin_start(obj, id) {
                layer.confirm('确认要发布吗？', function (index) {
                    var re = status_change(id, '1');
                    if(re){
                    $(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,'+id+')" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">发布</span>');
                    $(obj).remove();
                    layer.msg('已发布!', {icon: 6, time: 1000});
                    }
                });
            }
        </script>
    </body>
</html>